<template>
  <div class="Svideo">
    <van-list
        v-model="loading"
        :finished="isEnd"
        finished-text="没有更多了"
        @load="getData"
      >
        <van-cell
          v-for="svideo in Svideo"
          :key="`svideo-${svideo.id}`"
        >
          <!-- 使用 title 插槽来自定义标题 -->
          <template #title>
            <div class="Svideo-main">
              <img :src="`${svideo.video.imgUrl}`" @click="toSvideoShow(svideo)" />
              <p>{{ svideo.title.slice(0,12) }}...</p>
              <div class="Svideo-item">
                <p>
                  <img :src="`${svideo.user.avatarurl}`">
                  <span>{{svideo.user.nickName}}</span>
                </p>
                <p>
                  <img src="//p1.meituan.net/moviemachine/5377c2c03dacf20b6e286e3e72dd57911272.png" alt="">
                  <span>{{svideo.upCount}}</span>
                </p>
              </div>
            </div>
          </template>
        </van-cell>
      </van-list>
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
export default {
  name: 'Svideo',
  data () {
    return {
      Svideo: [],
      isEnd: false,
      loading: true
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      this.$http.getSvideo().then((resp) => {
        const { feeds } = resp.data.data
        this.Svideo = this.Svideo.concat(feeds)
        // console.log(this.Svideo)
        this.isEnd = false
        this.loading = false
      })
    },
    ...mapMutations(['seesvideo']),
    toSvideoShow (svideo) {
      this.seesvideo({
        surl: svideo.video.url,
        stitle: svideo.title
      })
      this.$router.push('/svideoinfo')
    }
  }
}
</script>

<style lang='scss' scoped>
.Svideo {
  display: flex;
  flex-wrap: wrap;
    .Svideo-main {
      width: 100%;
      height: 100%;
      img {
        width: 150%;
        height: 150%;
      }
      >p {
        position: absolute;
        left: 5px;
        bottom: 45px;
        font-size: 16px;
        color: white;
      }
      .Svideo-item {
        position: absolute;
        left: 8px;
        bottom: 5px;
        display: flex;
        justify-content: space-between;
        width: 95%;
        height: 20px;
        >p {
          padding: 0 6px;
          display: flex;
          align-items: center;
          color: white;
          font-size: 12px;
          img:nth-of-type(1) {
            border-radius: 50%;
          }
          img{
            margin-right: 5px;
          }
        }
        img {
          width: 18px;
          height: 18px;
        }
      }
  }
}
.van-cell__title {
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  border: 2px solid white;
}
.van-cell {
  width: 50%;
  height: 250px;
  padding: 4px 1px;
}
.van-list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
</style>
